<?php

class Artists {

    private $_artists = array();

    public function getArtists() {
        return $this->_artists;
    }

    public function setArtists($artists) {
        $this->_artists = $artists;
        return $this;
    }

    public function addArtist($artist) {
        array_push($this->_extraartists, $artist);
    }

    function __construct(array $donnees) {
        $this->hydrate($donnees);
    }

    public function __toString() {
        
    }

    public function hydrate(array $donnees) {
        foreach ($donnees as $key => $value) {
// On récupère le nom du setter correspondant à l'attribut.
            $method = 'set' . ucfirst($key);

// Si le setter correspondant existe.
            if (method_exists($this, $method)) {
// On appelle le setter.
                $this->$method($value);
            }
        }
    }

}

?>
